package com.aidex.quartz.task;

import com.aidex.quartz.service.ISysJobLogService;
import com.cmas.platform.cache.LoadData;
import com.cmas.platform.service.ReLoadRedisDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Author su
 * @Date 2024/9/3 18:11
 */
@Component("loadRedisDataTask")
public class LoadRedisDataTask {

    @Resource
    private ReLoadRedisDataService reLoadRedisDataService;

    @Autowired
    private ISysJobLogService jobLogService;

    /**
     * 重新加载缓存数据
     *
     * @param saveDay 日志保存多少天
     * @return
     */
    public String reloadRedisData(String saveDay) {
        String message = "";
        try {
            Long startTime = System.currentTimeMillis();
            reLoadRedisDataService.reloadRedisData();
            Long endTime = System.currentTimeMillis();
            message = "重新加载缓存数据操作日志成功耗时：（" + (endTime - startTime) + "）";
            jobLogService.deleteJobLogBySaveDay(saveDay);
        } catch (Exception e) {
            message = e.getLocalizedMessage();
        }
        return message;
    }

}
